<?php
/**
 * Created by Engineer CuiLiwu.
 * Project: deal.
 * Date: 2018/5/18-9:35
 * License Hangzhou orce Technology Co., Ltd. Copyright © 2018
 */

namespace App\Http\Controllers\Admin\GuestBook;
use App\Http\Controllers\Admin\BaseController;
use Illuminate\Http\Request;

class GuestBookController extends BaseController
{
    protected $api_url = [
        'index' => ['get', 'guestbook'],
        'show'  => ['get', 'guestbook/%d'],
    ];

    protected $request;

    public function __construct(Request $request)
    {
        $this->request = $request;
    }
    /**
     * 后台-文章列表
     * */
    public function index(){

        //参数部分
        $search_params = $this->request->all(['keyword','type']);

        $page = $this->request->get('page', 1);
        $params = [
            'search' => search_params($search_params),
            'searchJoin' => 'and',
            'orderBy'=>'created_at',
            'sortedBy'=>'desc',
            'page' => $page
        ];


        //请求部分
        $ret = http_admin($this->api_url['index'])->send($params);
        //结果处理部分
        $data = paginate($this->request, $ret['data']);

        //回填搜索框值
        $data['search_params'] = $search_params;

        return view('Admin.guestbook.index', $data);
    }

    public function create(){

    }

    public function store(){

    }


    public function show($id){
        
    }

    public function update($id){

    }
    
    public function destroy($id){
    }

}